<?php
namespace models\repositories;
use Doctrine\ORM\EntityRepository;
use entities;
class DokumenRepository extends EntityRepository {
	public function testIterate(){
		echo "<br>iterasi x";
	}
	public function findAllAsObject(){
		$qb = $this->_em->createQueryBuilder();		
		$qb->select('Dokumen')
		   ->from('models\entities\Dokumen', 'Dokumen')
			->leftJoin('Dokumen.jenisDok', 'a')
			->leftJoin('Dokumen.sifatDokumen', 'b')
			->leftJoin('Dokumen.grupDokumen', 'c')
			->leftJoin('Dokumen.kategoriDokumen', 'd')
			->leftJoin('Dokumen.divisi', 'e')
		;
		
		$query = $qb->getQuery();
		return $query->getResult();
	}


	public function findByIdAsObject($id){
		$qb = $this->_em->createQueryBuilder();		
		$qb->select('Dokumen')
		   ->from('models\entities\Dokumen', 'Dokumen')		   
		   ->where('Dokumen.id = ?1')
		;
		
		$qb->setParameter(1, $id);
		$query = $qb->getQuery();
		return $query->getResult();
	}

	public function findByKodeCepatAsObject($kodeCepat){
		$qb = $this->_em->createQueryBuilder();		
		$qb->select('Dokumen')
		   ->from('models\entities\Dokumen', 'Dokumen')			
			->where('Dokumen.kodeCepat = ?1')
		;
		$qb->setParameter(1, $kodeCepat);
		$query = $qb->getQuery();
		return $query->getResult();
	}
}

